package xaj.scc.ast;

import polyglot.ast.Block;
import polyglot.ast.Node;
import polyglot.ext.jl.ast.Node_c;
import polyglot.util.CodeWriter;
import polyglot.util.Position;
import polyglot.visit.NodeVisitor;
import polyglot.visit.PrettyPrinter;

public class SemanticAction_c extends Node_c implements SemanticAction {

	private Block block;
	
	public SemanticAction_c(Position pos, Block block) {
		super(pos);
		this.block = block;
	}

	public Block getBlock() {
		return block;
	}

	public SemanticAction setBlock(Block block) {
		SemanticAction_c n = (SemanticAction_c) copy();
		n.block = block;
		return n;
	}

	protected SemanticAction_c reconstruct(Block block) {
		if(this.block != block) {
			SemanticAction_c n = (SemanticAction_c) copy();
			n.block = block;
			return n;
		}
		return this;
	}
	
	public Node visitChildren(NodeVisitor v) {
		/*if(block != null) {
			Block block = (Block) this.block.visitChildren(v);
			return reconstruct(block);
		}*/
		return this;
	}
	
	public void prettyPrint(CodeWriter w, PrettyPrinter tr) {
		if(block != null) {
			if (block.statements().size() > 0) {
				block.prettyPrint(w, tr);
			}
		}
	}
	
	@Override
	public void accept(Visitor v) {
		v.visitSemanticAction(this);
	}
	
}
